package com.yyc.bleem;

import com.yyc.bleem.common.constant.BaseConstant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author yyc
 */
@EnableFeignClients
@SpringBootApplication
public class MicroCustomerServiceApplication {

    public static void main(String[] args) throws UnknownHostException{
        ConfigurableApplicationContext application = SpringApplication.run(MicroCustomerServiceApplication.class, args);
        String ip = InetAddress.getLocalHost().getHostAddress();
        Environment env = application.getEnvironment();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        String profiles = env.getProperty("spring.profiles.active");
        if(BaseConstant.testEnv.equals(profiles)){
            profiles = "测试";
        }else{
            profiles = "正式";
        }
        if (StringUtils.isEmpty(path)) {
            path = "";
        }
        System.out.println("\n----------------------------------------------------------\n\t" +
                "微服务-消费者" + profiles +"环境启动成功! Access URLs:\n\t" +
                "Local访问网址: \t\thttp://localhost:" + port + path + "\n\t" +
                "External访问网址: \thttp://" + ip + ":" + port + path + "\n\t" +
                "接口文档: \thttp://" + ip + ":" + port + path + "doc.html\n\t" +
                "----------------------------------------------------------");
    }

}
